/**
 * Created by GYL on 2018/7/25
 */
import React, { Component } from 'react';
import { Row, Col, Tabs, Card, InputNumber, Popover, Tag } from 'antd';
import Container from '../../components/common/Container';
import MyTable from '../../components/common/MyTable';
import PublicService from '../../services/PublicService';
import request from '../../utils/request';
import moment from 'moment';
import style from './RepDetails.less';
const TabPane = Tabs.TabPane;
var dataSource1 = [

]
class RepAirDetails extends Component {
    constructor(props) {
        super(props)
        this.columns = [
            {
                title: '序号',
                dataIndex: 'num',
                width: '5%',
                align: "center",
                key: "1"
            },
            {
                title: '时间',
                dataIndex: 'takeTime',
                width: '15%',
                align: "center",
                key: "2",

            },
            {
                title: '燃气站点',
                dataIndex: 'standName',
                width: '15%',
                key: "3",
                align: "center",

            },
            {
                title: '11.6Kg余气量/瓶',
                dataIndex: 'number116',
                width: '10%',
                key: "4",
                align: "center",

            },
            {
                title: '14.5Kg余气量/瓶',
                width: '10%',
                dataIndex: 'number145',
                align: "center",
                key: "5",

            },
            {
                title: '50Kg余气量/瓶',
                dataIndex: 'number500',
                width: '10%',
                align: "center",
                key: "6"
            },
            {
                title: '记录人',
                dataIndex: 'recorder',
                width: '17%',
                align: "center",
                key: "7"
            },

        ];

    }
    state = {
        loading: false,
        selectedRowKeys: [],
        selectedRows: [],
        dataSource: [],
        pageIndex: 1,
        pageSize: 10,
        enterprise:"",
        name: "",
        number116: "",
        number145: "",
        number500: "",
    }

    componentDidMount() {




        //查询进气台账
        this.onJqSave(1, 10)
    }

    onJqSave = (page, rows) => {
        let data = {
            page, rows,
            standId: PublicService.getCookie("RepPanId"),
            takeTime: PublicService.getCookie("RepPanTime")
        }
        request({
            url: `/zhrq-web/gas/airsuction/getParticulars`,
            method: 'POST',
            data: data
        }).then(data => {
            console.log(data)

            if (data.rc == 0) {
                data.ret.queryResult.items.forEach((item) => {
                    item.takeTime = moment(item.takeTime).format("YYYY-MM-DD HH:mm")
                })
                const { name, number116, number145, number500,enterprise } = data.ret
                this.setState({
                    name, number116, number145, number500,enterprise,
                    dataSource: data.ret.queryResult.items
                })
            }
        })
    }

    onA = () => {
        this.props.history.goBack()
    }
    render() {
        const { loading, selectedRowKeys, dataSource, pageIndex, pageSize, name, number116, number145, number500 ,enterprise} = this.state
        const windowWidth = document.body.clientWidth;
        const columns = this.columns
        const height = document.body.clientHeight;
        let containerHeight = '88vh';
        if (windowWidth > 1367) {
            containerHeight = '88vh';
        }

        return (
            <div className={style.wrap}>
                <Container
                    style={{ height: containerHeight, position: "relative", marginTop: "1vh", padding: "0px 10px" }}
                    header={true}
                >
                    <Row>
                        <Col span={12}><a onClick={this.onA}>库存管理</a> >> 详情</Col>
                        <Col span={12}><a onClick={this.onA} style={{ float: "right" }}>返回</a></Col>
                    </Row>

                    <Row>
                        <Col span={4}>企业 : {enterprise}</Col>

                        <Col span={4}>燃气站点 : {name}</Col>
                        <Col span={4}>时间 : {PublicService.getCookie("RepPanTime")}</Col>
                    </Row>

                    <Row>
                        <Col span={4}>当日进气量</Col>
                        <Col span={4}>11.6Kg : <InputNumber value={number116} size="small" disabled={true} /></Col>
                        <Col span={4}>14.5Kg : <InputNumber value={number145} size="small" disabled={true} /></Col>
                        <Col span={4}>50Kg : <InputNumber value={number500} size="small" disabled={true} /></Col>
                    </Row>
                    <Popover placement="bottomLeft" content={
                        <div>
                            <a>本页 ?</a><br />
                            <a>全部 ?</a>
                        </div>

                    } trigger="click">
                        <Tag color="#108ee9">导出</Tag>
                    </Popover>



                    <MyTable
                        // bordered
                        loading={loading}
                        columns={columns}
                        // rowSelection={rowSelection}
                        pagination={false}
                        // scroll={{ y: windowWidth < 1400 ? height - 280 : height - 300 }}
                        dataSource={PublicService.transformArrayData(dataSource, true, true, pageIndex, pageSize)}
                    />



                </Container>
            </div>
        )
    }
}
export default (RepAirDetails);
